package bean;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

@Entity
@Table(name="type")
public class Type implements java.io.Serializable{
	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Integer typeId;
	@Column(name="NAME")
	private String name;
	@OneToMany
	@JoinColumn(name="TYPE_ID")
	@Cascade(value={CascadeType.ALL})
	private Set<House> houses = new HashSet<House>();
	
	public Type() {
	}
	public Type(String name) {
		this.name = name;
	}
	public Type(String name, Set houses) {
		this.name = name;
		this.houses = houses;
	}
	public Integer getTypeId() {
		return typeId;
	}
	public void setTypeId(Integer typeId) {
		this.typeId = typeId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Set<House> getHouses() {
		return houses;
	}
	public void setHouses(Set<House> houses) {
		this.houses = houses;
	}
	@Override
	public String toString() {
		return "Type [typeId=" + typeId + ", name=" + name + ", houses=" + houses + "]";
	}
}
